package com.masterclient.app.businessmodule.vipmodule.card;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.masterclient.app.R;
import com.masterclient.app.businessmodule.vipmodule.bean.Level;
import com.masterclient.app.widget.GlideRoundTransform;

import butterknife.BindView;

/**
 * 银卡及以上会员
 */
public class OtherCard extends IBaseCard<Level> {
    @BindView(R.id.bg_iv)
    ImageView bgIv;
    @BindView(R.id.title1_tv)
    TextView title1Tv;
    @BindView(R.id.title2_tv)
    TextView title2Tv;
    @BindView(R.id.open_tv)
    TextView openTv;
    private RequestOptions options;
    public OtherCard(View itemView, Context context) {
        super(itemView, context);
        options = new RequestOptions();
        options.transform(new GlideRoundTransform(context, 8,GlideRoundTransform.RADIUSTOP));
    }

    @Override
    public void onBindViewHolder(Level level, int i) {
        String name = level.getLevel_name();
        String eName = level.getLevel_english_name();
        title1Tv.setText(name);
        title2Tv.setText(eName);
        String bg = level.getLevel_bg();
        Glide.with(mContext).load(bg).apply(options).into(bgIv);
        int l = level.getLevel();
        if(3 == l){// 银卡
            setTextColor(R.color.color_687184);
        }else if(4 == l){// 金卡
            setTextColor(R.color.color_8C6233);
        }else if(5 == l){// 黑卡
            setTextColor(R.color.color_353535);
        }else if(6 == l){// 经销商
            setTextColor(R.color.color_634083);
        }else if(7 == l){// 服务商
            setTextColor(R.color.color_3B557C);
        }else if(8 == l){// 合伙人
            setTextColor(R.color.color_7DF6FD);
        }
        openTv.setText(level.getBtnText());
    }

    /**
     * 设置会员等级设置字体颜色
     * @param color
     */
    private void setTextColor(int color){
        title1Tv.setTextColor(mContext.getResources().getColor(color));
        title2Tv.setTextColor(mContext.getResources().getColor(color));
    }
}
